Name | <ListTag.sort[<procedure>]> |
Returns | ListTag |
Description | Returns a list sorted according to the return values of a procedure.
The <procedure> should link a procedure script that takes two definitions each of which will be an item in the list, and returns -1, 0, or 1 based on whether the second item should be added. EG, if a procedure with definitions "one" and "two" returned -1, it would place "two" after "one". Note that this uses some complex internal sorting code that could potentially throw errors if the procedure does not return consistently - EG, if "one" and "two" returned 1, but "two" and "one" returned 1 as well - obviously, "two" can not be both before AND after "one"! Note that the script should ALWAYS return -1, 0, or 1, or glitches could happen! Note that if two inputs are exactly equal, the procedure should always return 0. |
Source | https://github.com/DenizenScript/Denizen-Core/blob/master/src/main/java/com/denizenscript/denizencore/objects/core/ListTag.java#L2250 |